package com.yswy.domain.entity.tf;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yswy.domain.vo.dto.TgDeviceKs;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.zip.CRC32;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Api(tags = "推广回传记录表（快手）")
@TableName(value = "tg_call_back_ks_id")
public class TgCallBackKsId {
    @TableId(type = IdType.AUTO)
    private Long id;

    @ApiModelProperty("渠道")
    private String channel;
    @ApiModelProperty("渠道包")
    private String packChannel;
    @ApiModelProperty("项目ID")
    private Long projectId;
    @ApiModelProperty("广告计划ID")
    private String dId ;
    @ApiModelProperty("广告组ID")
    private String aId  ;
    @ApiModelProperty("广告创意ID")
    private String cId  ;
    @ApiModelProperty("广告计划名称")
    private String dName  ;
    @ApiModelProperty("广告组名称")
    private String unitName  ;
    @ApiModelProperty("设备标识计算MD5")
    private String oaid  ;
    @ApiModelProperty(" IMEI的MD5")
    private String imei  ;
    @ApiModelProperty("iOS下的idfa计算MD5")
    private String idfa  ;
    @ApiModelProperty(" MAC 进行 MD5")
    private String mac ;
    @ApiModelProperty("ANDROIDID进行 MD5")
    private String android ;
    @ApiModelProperty("客户端UA")
    private String ua ;
    @ApiModelProperty("OS系统1-iOS，0-安卓")
    private String os  ;
    @ApiModelProperty("手机型号")
    private String model ;
    private String modelIp;
    @ApiModelProperty("回调信息")
    private String callback;
    private Long callbackparamCrc;
    @ApiModelProperty("ip地址")
    private String channelIp ;
    @ApiModelProperty("创建时间")
    private Date createTime;

    public TgCallBackKsId(String channel ,String packChannel,Long projectId, TgDeviceKs tgDeviceKs  ) {
        this.channel = channel;
        this.packChannel = packChannel;
        this.projectId = projectId;
        this.dId = tgDeviceKs.getDID();
        this.aId = tgDeviceKs.getAID();
        this.cId  = tgDeviceKs.getCID();
        this.dName = tgDeviceKs.getDNAME();
        this.unitName = tgDeviceKs.getUNITNAME();
        this.oaid = tgDeviceKs.getOAID2().replaceAll("\\s" , "");
        this.imei = tgDeviceKs.getIMEI2();
        this.idfa = tgDeviceKs.getIDFA2();
        this.mac = tgDeviceKs.getMAC2();
        this.android = tgDeviceKs.getANDROIDID2();
        this.ua = tgDeviceKs.getUA();
        this.os = tgDeviceKs.getOS();
        this.model = tgDeviceKs.getMODEL();
        this.channelIp = tgDeviceKs.getIP();
        this.callback = tgDeviceKs.getCALLBACK();
        CRC32 callbackparamCrc32 = new CRC32();
        callbackparamCrc32.update(tgDeviceKs.getCALLBACK().getBytes());
        this.callbackparamCrc = callbackparamCrc32.getValue();
        this.modelIp  = tgDeviceKs.getMODEL().replaceAll("\\s" , "") + tgDeviceKs.getIP();
        this.createTime = new Date();
    }


    public static void main(String[] args) {
        CRC32 crc32 = new CRC32();
        crc32.update("c.rqB7I6enkYhGUseoWmFQtifecPLHpOOe7BRx0jOyNqXj7D16SjahWOiMzZsC7rKngpJJeoTQt3JZeLYf9ejgDqesRTRqR34memQ4RNFfa7TnkfPfXffyj1nypdVoSA7Yoms12ZPVyWM8J8HKDLuYgtJE".getBytes());
        System.out.println(crc32.getValue());
    }

}
